﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NetMsSqlLibrary
{
    public class WhereList
    {
        public enum Comparison
        {
            等于 = 0,
            不等于 = 1,
            大于 = 2,
            小于 = 3,
            大于等于 = 4,
            小于等于 = 5,
        };
        private String ComparisonMap(Comparison comparison)
        {

            switch (comparison)
            {
                case Comparison.等于:
                    return "=";
                case Comparison.不等于:
                    return "<>";
                case Comparison.大于:
                    return ">";
                case Comparison.小于:
                    return "<";
                case Comparison.大于等于:
                    return ">=";
                case Comparison.小于等于:
                    return "<=";
                default:
                    return null;
            }
        }

        public string WhereStr { get; set; }
        public void add(string field, Comparison comparison,string value)
        {
            try
            {
                //if (WhereStr != null || WhereStr.Length != 0)
                //{
                //    WhereStr = WhereStr + " and ";
                //}
                WhereStr = WhereStr + " and " + field + ComparisonMap(comparison) + "'" + value + "'";
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
    }
}
